﻿using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Exepack;

namespace ExepackTests
{
	/// <summary>
	/// Tests for CompressionOptions
	/// </summary>
	[TestClass]
	public class CompressionOptionsTest
	{
		public TestContext TestContext { get; set; }

		[TestMethod]
		public void CompressionOptions_CreateLoadsAssemblyWithReferences()
		{
			var c = CompressionOptions.Create(GetType().Assembly.Location);

			Assert.IsNotNull(c);
			Assert.IsTrue(c.MainAssembly.AsmName.Name == "ExepackTests");
			Assert.IsTrue(c.OutputAssemblyName == "ExepackTestsLoader");
			Assert.IsTrue(c.OutputFileName == "ExepackTests.packed.exe");
			Assert.IsTrue(c.AdditionalAssemblies != null);
			Assert.IsTrue(c.AdditionalAssemblies.Count > 0);
		}

		[TestMethod]
		public void CompressionOptions_AddOneReference()
		{
			var c = CompressionOptions.Create("Exepack.exe");
			var count = c.AdditionalAssemblies.Count;

			// exactly one new reference
			c.Add("WinExepack.exe");
			Assert.IsTrue(c.AdditionalAssemblies.Count == count + 1);
		}

		[TestMethod]
		public void CompressionOptions_AddRecursiveReferences()
		{
			var c = CompressionOptions.Create("Exepack.exe");
			var count = c.AdditionalAssemblies.Count;

			// at least one extra reference to MS Unit Testing assembly
			c.AddRecursive(GetType().Assembly.Location);
			Assert.IsTrue(c.AdditionalAssemblies.Count > count + 1);
		}
	}
}
